import com.dmotiko.util.*
import com.dmotiko.zonaoutlet.*
import com.dmotiko.general.*
import mx.utils.Delegate;
import mx.transitions.*
import mx.transitions.easing.*

class ZOMainContent
extends BaseClip {
	
	private var mcHome:MovieClip;
	private var mcQuienesSomos:MovieClip;
	private var mcBuscador:MovieClip;
	private var mcPromociones:MovieClip;
	private var mcVIP:MovieClip;
	private var mcAtencion:MovieClip;
	private var activeSection:MovieClip;
	
	private var mcl:MovieClipLoader;
	
	private function ZOMainContent() {
		ZOSite.getApp().setMainContent(this);
		ZOSite.getApp().addEventListener( ZOSite.SECTION_CHANGED, Delegate.create(this, sectionChanged));
				
		this.mcl = new MovieClipLoader();
		mcl.addListener(this);
		
		this.mcHome = this.createEmptyMovieClip("mcHome", this.getNextHighestDepth());
		this.mcQuienesSomos = this.createEmptyMovieClip("mcQuienesSomos", this.getNextHighestDepth());
		this.mcBuscador = this.createEmptyMovieClip("mcBuscador", this.getNextHighestDepth());
		this.mcPromociones = this.createEmptyMovieClip("mcPromociones", this.getNextHighestDepth());
		this.mcVIP = this.createEmptyMovieClip("mcVIP", this.getNextHighestDepth());
		this.mcAtencion = this.createEmptyMovieClip("mcAtencion", this.getNextHighestDepth());
		
		mcl.loadClip("home.swf", mcHome);
		mcl.loadClip("quienesSomos.swf", mcQuienesSomos);
		mcl.loadClip("mcBuscador.swf", mcBuscador);
		mcl.loadClip("mcPromociones.swf", mcPromociones);
		mcl.loadClip("mcVIP.swf", mcVIP);
		mcl.loadClip("mcAtencion.swf", mcAtencion);
		
	}
		
	public function onLoadInit(target) {
		target._visible = false;
		if(target == mcHome) sectionChanged();
	}
	
	private function sectionChanged() {
		if(activeSection){
			//activeSection.interpolator = activeSection.fadeOut( { listener: activeSectionOut, bind: this, rate: 5 } );
			//activeSection.interpolator = new Fade( activeSection, { }, 
		}
		
		var sSection:String = ZOSite.getApp().getSection();
		switch( sSection ) {
			case ZOSite.HOME:
			activeSection = mcHome;
			break;
			
			case ZOSite.QUIENES_SOMOS:
			activeSection = mcQuienesSomos;
			break;
			
			case ZOSite.BUSCADOR:
			activeSection = mcBuscador;
			break;
			
			case ZOSite.PROMOCIONES:
			activeSection = mcPromociones;
			break;
			
			case ZOSite.VIP:
			activeSection = mcVIP;
			break;
			
			case ZOSite.ATENCION:
			activeSection = mcAtencion;
			break;
		}
		
		activeSection.interpolator.stopEffect();
		activeSection._visible = true;
		activeSection.fadeIn( { rate: 5} );
		
	}
	
	private function activeSectionOut(clip) {
		clip._visible = false;
	}
	
}